﻿using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.StackExchangeRedis;
using my_webapi_demo.Common;

namespace my_webapi_demo.Ext;

public static class CacheEx
{
    public static void AddRedisCache(this IServiceCollection services)
    {
        var redisCache = new RedisCache(new RedisCacheOptions()
        {
            Configuration = AppConfig.Settings.RedisConnection,
            InstanceName = AppConfig.Settings.InstanceName,
        });

        services.AddSingleton<IDistributedCache>(redisCache);
    }
}
